-- master_oogway
-- created by panyl
-- 地牢格子：乌龟大师

-- 随机一下数组/两两交换
local function randomTable(arr)
    for oriIndex, value in pairs(arr) do
        local toIndex = math.random(#arr);
        local temp = arr[toIndex];
        arr[toIndex] = arr[oriIndex];
        arr[oriIndex] = temp;
    end
    return arr;
end

return {
    autoFight = function(grid)
        local dungeonId = DungeonM.getDungeonId();
        local layer = DungeonM.currentLayer();
        if DungeonBossM.isBossLayer(dungeonId, layer)
            and not DungeonM.isAllMonsterDead() then
            -- boss层要等boss被击杀
            return false;
        end

        local pos = grid:getPos();
        local items = {7035, 9022, 9047, 9044, 8062, 7216};
        items = randomTable(items);
        for _, classId in pairs(items) do
            if DungeonActionM.go("master_oogway", pos, classId) then
                return true;
            end
        end
        return false;
    end,
};
